import 'package:flutter/material.dart';
import 'package:untitled/pages/login_widget/Home/community_widget.dart';
import 'package:untitled/pages/login_widget/Home/manager_widget.dart';
import 'package:untitled/pages/login_widget/Home/my_profile.dart';

class home extends StatefulWidget {
  const home({Key? key}) : super(key: key);

  @override
  State<home> createState() => _homeState();
}

// 自定义的主页
class _homeState extends State<home> {
  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      length: 3, 
      child: Scaffold(
        //用DefaultTabController包围,使每一个Tabbar都能对应一个页面
        appBar: PreferredSize(
          child: AppBar(
            title:Text("flutter profile"),
            centerTitle: true, // 居中
            actions: [
              // 右侧行为按钮
              IconButton(
                onPressed: null, 
                icon: Icon(Icons.cast),
                color: Colors.black,
                )
            ],
          ),
          preferredSize: Size.fromHeight(45),
        ),
        drawer: Drawer(
          // 侧面栏
          child: ListView(
            //一个列表// 抽屉可能在高度上超出屏幕，所以使用 ListView 组件包裹起来，实现纵向滚动效果
              // 干掉顶部灰色区域
              padding: EdgeInsets.all(0),
              children: [
                UserAccountsDrawerHeader(
                  accountName: Text("LINXIHONG"), 
                  accountEmail: Text("qdl.cs@qq.com"),
                  currentAccountPicture: CircleAvatar(
                    backgroundImage:NetworkImage('https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fc-ssl.duitang.com%2Fuploads%2Fblog%2F202008%2F16%2F20200816161457_gkcfb.thumb.1000_0.jpg&refer=http%3A%2F%2Fc-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1658071458&t=3270c38ca14b2767b9ee00ebbdfc43e5')
                  ),
                decoration: BoxDecoration(
                  image: DecorationImage(
                    fit: BoxFit.cover,
                    image:NetworkImage(
                      'https://pic2.zhimg.com/80/v2-5667cfc00148b02c8aff3f3bc966bacd_720w.jpg'))
                ),
                ),
                ListTile(
                  title: Text('用户反馈'),
                  trailing: Icon(
                    Icons.feedback,
                    color: Colors.blue,
                  ),
                ),
                Divider(),
                ListTile(
                  title: Text('系统设置'),
                  trailing: Icon(
                    Icons.settings,
                    color: Colors.green,
                  ),
                ),
                Divider(),
                ListTile(
                  title: Text('发布'),
                  trailing: Icon(
                    Icons.send,
                    color: Colors.deepPurpleAccent,
                  ),
                ),
                Divider(),
                ListTile(
                  title: Text('注销'),
                  trailing: Icon(
                    Icons.exit_to_app,
                    color: Colors.amberAccent,
                  ),
                ),

              ],

          ),
        ),
        // 底部导航栏
        bottomNavigationBar: Container(
          decoration: BoxDecoration(
            color: Colors.blue,
            borderRadius: BorderRadius.circular(3)
          ),
          height: 50, // tabbar 高度为50
          child: TabBar(
             labelStyle: TextStyle(height: 0, fontSize: 10),
            tabs: <Widget>[
              Tab(
                icon: Icon(Icons.supervised_user_circle_outlined),
                text: "Community",
              ),
              Tab(
                icon: Icon(Icons.keyboard),
                text: "Manager",
              ),
              Tab(
                icon: Icon(Icons.account_box),
                text: "MyProfile",
              ),
            ],

          ),
        ),
        body: TabBarView(children: [
          Community(),
          Manager(),
          MyProfile(),
          
        ]),
      ));
  }
}